//
//  UIScrollView+SEGExtension.m
//  RefreshDemo
//
//  Created by Clavis on 2019/1/2.
//  Copyright © 2019 Clavis. All rights reserved.
//

#import "UIScrollView+SEGExtension.h"

@implementation UIScrollView (SEGExtension)

- (UIEdgeInsets)seg_inset
{
    if (@available(iOS 11, *)) {
        return self.adjustedContentInset;
    } else {
        return self.contentInset;
    }
}

- (void)setSeg_insetT:(CGFloat)seg_insetT
{
    UIEdgeInsets inset = self.contentInset;
    inset.top = seg_insetT;
    if (@available(iOS 11, *)) {
        inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
    }
    self.contentInset = inset;
}

- (CGFloat)seg_insetT
{
    return self.seg_inset.top;
}

- (void)setSeg_insetB:(CGFloat)seg_insetB
{
    UIEdgeInsets inset = self.contentInset;
    inset.bottom = seg_insetB;
    if (@available(iOS 11, *)) {
        inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
    }
    self.contentInset = inset;
}

- (CGFloat)seg_insetB
{
    return self.seg_inset.bottom;
}

- (void)setSeg_insetL:(CGFloat)seg_insetL
{
    UIEdgeInsets inset = self.contentInset;
    inset.left = seg_insetL;
    if (@available(iOS 11, *)) {
        inset.left -= (self.adjustedContentInset.left - self.contentInset.left);
    }
    self.contentInset = inset;
}

- (CGFloat)seg_insetL
{
    return self.seg_inset.left;
}

- (void)setSeg_insetR:(CGFloat)seg_insetR
{
    UIEdgeInsets inset = self.contentInset;
    inset.right = seg_insetR;
    if (@available(iOS 11, *)) {
        inset.right -= (self.adjustedContentInset.right - self.contentInset.right);
    }
    self.contentInset = inset;
}

- (CGFloat)seg_insetR
{
    return self.seg_inset.right;
}

- (void)setSeg_offsetX:(CGFloat)seg_offsetX
{
    CGPoint offset = self.contentOffset;
    offset.x = seg_offsetX;
    self.contentOffset = offset;
}

- (CGFloat)seg_offsetX
{
    return self.contentOffset.x;
}

- (void)setSeg_offsetY:(CGFloat)seg_offsetY
{
    CGPoint offset = self.contentOffset;
    offset.y = seg_offsetY;
    self.contentOffset = offset;
}

- (CGFloat)seg_offsetY
{
    return self.contentOffset.y;
}

- (void)setSeg_contentW:(CGFloat)seg_contentW
{
    CGSize size = self.contentSize;
    size.width = seg_contentW;
    self.contentSize = size;
}

- (CGFloat)seg_contentW
{
    return self.contentSize.width;
}

- (void)setSeg_contentH:(CGFloat)seg_contentH
{
    CGSize size = self.contentSize;
    size.height = seg_contentH;
    self.contentSize = size;
}

- (CGFloat)seg_contentH
{
    return self.contentSize.height;
}

@end
